package com.xiao.controller;

import com.xiao.common.Constants;
import com.xiao.common.Result;
import com.xiao.common.dto.UserDto;
import com.xiao.server.RegisterServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.*;

@RestController
public class RegisterController {
    @Autowired
    private RegisterServer registerServer;

    @PostMapping("/register")
    public Result register(@RequestBody UserDto userDto){
        if (userDto.getUserId() == null || userDto.getPassword() == null){
            return Result.error(Constants.CODE_400,"请输入帐号和密码!");
        }

        return registerServer.registerUser(userDto);
    }
}
